package com.diaohw.platform.utility.uml.core.enums;

import java.lang.reflect.Modifier;

public enum ClassTypeEnum {

    ENUM("enum"),
    INTERFACE("interface"),
    ABSTRACT("abstract"),
    NORMAL("class");

    public final String name;

    ClassTypeEnum(String name) {
        this.name = name;
    }

    public static ClassTypeEnum format(Class<?> clazz) {
        int modifiers = clazz.getModifiers();
        if (clazz.isInterface()) {
            return INTERFACE;
        }
        if (clazz.isEnum()) {
            return ENUM;
        }
        if (Modifier.isAbstract(modifiers)) {
            return ABSTRACT;
        }
        return NORMAL;
    }
}
